import { Injectable } from '@angular/core';
import { HttpService } from './http.service';

import { Store } from '@ngrx/store';
import { AppState } from '../../interfaces';
import { Response } from '@angular/http';
import { User } from '../class/user';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class UserService {

  constructor(
    private http: HttpService,
    private store: Store<AppState>
  ) { }

  /**
   *
   *
   * @returns {Observable<User>}
   *
   * @memberof UserService
   */
  getUser(): Observable<User> {
    const user_id = JSON.parse(localStorage.getItem('user')).id;
    return this.http.get(`spree/api/v1/users/${user_id}`)
      .map(res => res.json());
  }

}
